/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistencia;

import java.sql.*;


/**
 *UPDATE USER SET PASSWORD=PASSWORD('nuevo_pass') WHERE USER='root';
 * @author JAVA
 */
public class PersistenciaConexion {
    static String host      = "localhost";
    static String baseDatos = "thenet";
    static String usuario   = "root";
    static String password  = "root";
    
    public static Connection con;
    public static Statement st;
    
    /**
     * Crea la conexion con la BBDD THENET
     * @throws ClassNotFoundException
     * @throws IllegalAccessException
     * @throws InstantiationException
     * @throws SQLException 
     */
     public static void crearConexion() throws ClassNotFoundException, IllegalAccessException, InstantiationException, SQLException {
        Class.forName("com.mysql.jdbc.Driver").newInstance();
            
        // Establecemos la conexión con la base de datos. 
        con = DriverManager.getConnection("jdbc:mysql://"+host+"/"+baseDatos,usuario, password);
        st = con.createStatement();
    }
     
     /**
     * Cierra la conexion con la BBDD
     */
     public static void cerrarConexion() {
         try {
             if (st != null) {
                 st.close();
             }
             if (con != null) {
                 con.close();
             }
         } catch (SQLException e) {
        
         }
    } 
    
}
